package com.stylefeng.guns.rest.modular.auth.controller.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.stylefeng.guns.rest.modular.auth.validator.dto.Credence;
import com.stylefeng.guns.rest.validater.Search;
import com.stylefeng.guns.rest.validater.Update;
import com.stylefeng.guns.rest.validater.Verify;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 认证的请求dto
 *
 * @author fengshuonan
 * @Date 2017/8/24 14:00
 */
@Data
@ApiModel(value = "认证的请求dto",description = "认证的请求dto")
public class AuthRequest implements Credence {
    @ApiModelProperty(value="司机手机号",name="userName",required = true)
    @NotNull(message = "司机手机号不能为空",groups ={Search.class,Verify.class,Update.class})
    @Pattern(regexp="^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$", message="手机号格式不正确")
    private String userName;
    @ApiModelProperty(value="密码",name="password",required = true)
    @NotNull(message = "密码不能为空",groups ={Verify.class,Update.class})
    private String password;
    @ApiModelProperty(value="新密码",name="npasswd")
    @NotNull(message = "新密码不能为空",groups = Update.class)
    private String npasswd;//新密码
    @ApiModelProperty(value="驾驶员登录的设备id",name="diClientId")
    @NotNull(message = "驾驶员登录的设备id不能为空",groups =Verify.class)
    private String diClientId;//驾驶员登录的设备id
    @ApiModelProperty(value="(登录|修改)类型 0:密码(登录|修改) 2:验证码(登录|修改)",name="type")
    @NotNull(message = "验证类型不能为空",groups ={Verify.class,Update.class})
    private Integer type;
    @Override
    @JsonIgnore
    public String getCredenceName() {
        return this.userName;
    }
    @Override
    @JsonIgnore
    public String getCredenceCode() {
        return this.password;
    }

    @Override
    @JsonIgnore
    public String getClicode() {
        return this.diClientId;
    }
}
